package Test;

import org.junit.Test;

import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.demo.entity.Course;
import com.demo.service.CourseService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/spring-*.xml")
public class CourseTest {
	@Autowired
	private CourseService courseService;
	
	@Test
	public void add()throws Exception{
		Course course = new Course();
		course.setId("co3");
		course.setCoursename("政治");
		int addCourse = courseService.addCourse(course );
		System.out.println(addCourse);
	}
	
	@Test
	public void delete()throws Exception{
		int deleteCourseById = courseService.deleteCourseById("co3");
		System.out.println(deleteCourseById);
	}
	
	@Test
	public void selectById()throws Exception{
		Course selectCourseById = courseService.selectCourseById("co3");
		System.out.println(selectCourseById);
	}
	
	/*@Test
	public void select()throws Exception{
		List<Course> selectAllCourse = courseService.selectAllCourse();
		for (Course course : selectAllCourse) {
			System.out.println(course);
		}
	}*/
	
	@Test
	public void update()throws Exception{
		Course selectCourseById = courseService.selectCourseById("co3");
		selectCourseById.setCoursename("化学");
		int updateCourser = courseService.updateCourser(selectCourseById);
		System.out.println(updateCourser);
	}
}
